package application

import (
	"context"
	"zxstudy.com/domain/entity"
	"zxstudy.com/domain/repository"
)

type carApp struct {
	repo repository.CarRepository
}

type CarApplication interface {
	Create(ctx context.Context, car *entity.Car) (*entity.Car, error)
	Delete(ctx context.Context, car *entity.Car) error
	Get(ctx context.Context, id int) (*entity.Car, error)
	Cars(ctx context.Context) ([]*entity.Car, error)
}

func NewCarApplication(repo repository.CarRepository) *carApp {
	return &carApp{repo}
}

func (c *carApp) Create(ctx context.Context, car *entity.Car) (*entity.Car, error) {
	return c.repo.Create(ctx, car)
}

func (c *carApp) Delete(ctx context.Context, car *entity.Car) error {
	return c.repo.Delete(ctx, car)
}

func (c *carApp) Get(ctx context.Context, id int) (*entity.Car, error) {
	return c.repo.Get(ctx, id)
}

func (c *carApp) Cars(ctx context.Context) ([]*entity.Car, error) {
	return c.repo.Cars(ctx)
}